﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Core;

namespace MotionWinForm
{
    public partial class CaptureSourceForm : Form
    {
        FilterCollection filters;
		private string device;

		/// <summary>
		/// Required designer variable.
		/// </summary>
		//private System.ComponentModel.Container components = null;

		// Device
		public string Device
		{
			get { return device; }
		}

		// Constructor
        public CaptureSourceForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			try
			{
				filters = new FilterCollection(FilterCategory.VideoInputDevice);

				if (filters.Count == 0)
					throw new ApplicationException();

				// add all devices to combo
				foreach (Filter filter in filters)
				{
					comboBox1.Items.Add(filter.Name);
				}
			}
			catch (ApplicationException)
			{
				comboBox1.Items.Add("No local capture devices");
				comboBox1.Enabled = false;
				button1.Enabled = false;
			}

			comboBox1.SelectedIndex = 0;
		}


        private void button2_Click(object sender, EventArgs e)
        {
            // Cancel click
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // Ok click
            device = filters[comboBox1.SelectedIndex].MonikerString;
            
        }
    }
}
